package ru.lukyanets.torrent;

import java.time.ZonedDateTime;
import java.util.ArrayList;

/**
 * @author slukyanets
 */
@SuppressWarnings("unused")
public class TorrentInfo {

    private String announceURL;
    private String comment;
    private String createdBy;
    private ZonedDateTime creationDate;
    private String encoding;

    /**
     *  In case of multiple files torrent, saveAs is the name of a directory
     * and name contains the path of the file to be saved in this directory
     */
    private String saveAs;
    private int pieceLength;


    private final ArrayList<String> name = new ArrayList<>();
    private final ArrayList<Long> length = new ArrayList<>();

    private byte[] infoHash;
    private long totalLength;

    private final ArrayList<byte[]> pieceHash = new ArrayList<>();

    public String getAnnounceURL() {
        return announceURL;
    }

    public void setAnnounceURL(String announceURL) {
        this.announceURL = announceURL;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public ZonedDateTime getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(ZonedDateTime creationDate) {
        this.creationDate = creationDate;
    }

    public String getEncoding() {
        return encoding;
    }

    public void setEncoding(String encoding) {
        this.encoding = encoding;
    }

    public String getSaveAs() {
        return saveAs;
    }

    public void setSaveAs(String saveAs) {
        this.saveAs = saveAs;
    }

    public int getPieceLength() {
        return pieceLength;
    }

    public void setPieceLength(int pieceLength) {
        this.pieceLength = pieceLength;
    }

    public ArrayList<String> getName() {
        return name;
    }

    public ArrayList<Long> getLength() {
        return length;
    }

    public byte[] getInfoHash() {
        return infoHash;
    }

    public void setInfoHash(byte[] infoHash) {
        this.infoHash = infoHash;
    }

    public String getInfoHashAsUrl() {
        return null;
    }

    public long getTotalLength() {
        return totalLength;
    }

    public void setTotalLength(long totalLength) {
        this.totalLength = totalLength;
    }

    public ArrayList<byte[]> getPieceHash() {
        return pieceHash;
    }

    @Override
    public String toString() {
        return "Tracker URL: " + announceURL + '\n' +
                "Torrent created by : " + createdBy + '\n' +
                "Torrent creation date : " + creationDate + '\n' +
                "Info hash :\n" + "\t\t" + new String(infoHash);
    }
}